<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>忍者必须死三藏宝图活动计算器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 1000px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f9f9f9;
        }
        h1, h2 {
            color: #444;
            text-align: center;
        }
        .container {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: center;
        }
        th {
            background-color: #f2f2f2;
        }
        input, select {
            padding: 6px;
            border: 1px solid #ddd;
            border-radius: 4px;
            width: 100%;
            box-sizing: border-box;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            display: block;
            margin: 20px auto;
        }
        button:hover {
            background-color: #45a049;
        }
        .result-section {
            margin-top: 30px;
        }
        .section-title {
            border-bottom: 2px solid #eee;
            padding-bottom: 10px;
            margin-top: 30px;
        }
        .flex-container {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            margin-bottom: 20px;
        }
        .flex-item {
            flex: 1;
            min-width: 200px;
        }
    </style>
</head>
<body>
    <h1>忍者必须死三藏宝图活动计算器</h1>
    
    <div class="container">
        <h2 class="section-title">基本信息</h2>
        <div class="flex-container">
            <div class="flex-item">
                <label for="remainingDays">剩余天数:</label>
                <input type="number" id="remainingDays" min="0" max="28" value="28">
            </div>
            <div class="flex-item">
                <label for="remainingLegendaryMember">剩余神品队员奖励次数:</label>
                <input type="number" id="remainingLegendaryMember" min="0" max="8" value="8">
            </div>
            <div class="flex-item">
                <label for="weeklyLegendaryDrops">本周未掉落神品碎片数量:</label>
                <input type="number" id="weeklyLegendaryDrops" min="0" max="3" value="3">
            </div>
        </div>
        
        <!-- <h2 class="section-title">传颂藏宝图</h2> -->
        <div class="flex-container">
            <div class="flex-item">
                <label for="hasLegendLeader">已获得队长奖励:</label>
                <select id="hasLegendLeader">
                    <option value="false">否</option>
                    <option value="true" selected>是</option>
                </select>
            </div>
            <div class="flex-item">
                <label for="hasLegendMember">已获得队员奖励:</label>
                <select id="hasLegendMember">
                    <option value="false">否</option>
                    <option value="true" selected>是</option>
                </select>
            </div>
            <div class="flex-item">
                <label for="legendLeaderStar">队长奖励星级:</label>
                <select id="legendLeaderStar">
                    <option value="1">一星</option>
                    <option value="2">二星</option>
                    <option value="3">三星</option>
                    <option value="4" selected>四星</option>
                </select>
            </div>
            <div class="flex-item">
                <label for="legendMemberStar">队员奖励星级:</label>
                <select id="legendMemberStar">
                    <option value="1">一星</option>
                    <option value="2">二星</option>
                    <option value="3">三星</option>
                    <option value="4" selected>四星</option>
                </select>
            </div>
        </div>
        
        <h2 class="section-title">当前藏宝图碎片</h2>
        <table>
            <tr>
                <th>品级</th>
                <th>数量</th>
            </tr>
            <tr>
                <td>随机碎片</td>
                <td><input type="number" id="randomFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>凡品碎片</td>
                <td><input type="number" id="commonFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>珍品碎片</td>
                <td><input type="number" id="rareFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>绝品碎片</td>
                <td><input type="number" id="epicFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>神品碎片</td>
                <td><input type="number" id="legendaryFragments" min="0" value="0"></td>
            </tr>
        </table>
        
        <h2 class="section-title">当前藏宝图</h2>
        <table>
            <tr>
                <th>品级</th>
                <th>风</th>
                <th>雷</th>
                <th>水</th>
                <th>火</th>
            </tr>
            <tr>
                <td>凡品</td>
                <td><input type="number" id="commonWind" min="0" value="0"></td>
                <td><input type="number" id="commonThunder" min="0" value="0"></td>
                <td><input type="number" id="commonWater" min="0" value="0"></td>
                <td><input type="number" id="commonFire" min="0" value="0"></td>
            </tr>
            <tr>
                <td>珍品</td>
                <td><input type="number" id="rareWind" min="0" value="0"></td>
                <td><input type="number" id="rareThunder" min="0" value="0"></td>
                <td><input type="number" id="rareWater" min="0" value="0"></td>
                <td><input type="number" id="rareFire" min="0" value="0"></td>
            </tr>
            <tr>
                <td>绝品</td>
                <td><input type="number" id="epicWind" min="0" value="0"></td>
                <td><input type="number" id="epicThunder" min="0" value="0"></td>
                <td><input type="number" id="epicWater" min="0" value="0"></td>
                <td><input type="number" id="epicFire" min="0" value="0"></td>
            </tr>
            <tr>
                <td>神品</td>
                <td><input type="number" id="legendaryWind" min="0" value="0"></td>
                <td><input type="number" id="legendaryThunder" min="0" value="0"></td>
                <td><input type="number" id="legendaryWater" min="0" value="0"></td>
                <td><input type="number" id="legendaryFire" min="0" value="0"></td>
            </tr>
        </table>
        
        <h2 class="section-title">当前未获得的秘闻碎片</h2>
        <table>
            <tr>
                <th>类型</th>
                <th>数量</th>
            </tr>
            <tr>
                <td>随机碎片</td>
                <td><input type="number" id="secretRandomFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>凡品碎片</td>
                <td><input type="number" id="secretCommonFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>珍品碎片</td>
                <td><input type="number" id="secretRareFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>绝品碎片</td>
                <td><input type="number" id="secretEpicFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>神品碎片</td>
                <td><input type="number" id="secretLegendaryFragments" min="0" value="0"></td>
            </tr>
        </table>
        
        <h2 class="section-title">当前属性碎片</h2>
        <table>
            <tr>
                <th>属性</th>
                <th>数量</th>
            </tr>
            <tr>
                <td>风</td>
                <td><input type="number" id="windFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>雷</td>
                <td><input type="number" id="thunderFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>水</td>
                <td><input type="number" id="waterFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>火</td>
                <td><input type="number" id="fireFragments" min="0" value="0"></td>
            </tr>
            <tr>
                <td>通用</td>
                <td><input type="number" id="universalFragments" min="0" value="0"></td>
            </tr>
        </table>
        
        <h2 class="section-title">目标属性碎片</h2>
        <table>
            <tr>
                <th>属性</th>
                <th>目标数量</th>
            </tr>
            <!-- <tr>
                <td>风</td>
                <td><input type="number" id="targetWind" min="0" value="0"></td>
            </tr>
            <tr>
                <td>雷</td>
                <td><input type="number" id="targetThunder" min="0" value="0"></td>
            </tr>
            <tr>
                <td>水</td>
                <td><input type="number" id="targetWater" min="0" value="0"></td>
            </tr>
            <tr>
                <td>火</td>
                <td><input type="number" id="targetFire" min="0" value="0"></td>
            </tr> -->
            <tr>
                <td>通用</td>
                <td><input type="number" id="targetUniversal" min="0" value="0"></td>
            </tr>
        </table>
        
        <button id="calculateBtn">计算</button>
    </div>
    
    <div class="container result-section">

        
        

        <h2 class="section-title">剩余藏宝图碎片</h2>
        <table>
            <tr>
                <th>随机</th>
                <th>凡</th>
                <th>珍</th>
                <th>绝</th>
                <th>神</th>
            </tr>
            <tr>
                <td id="remainingRandomFragments">0</td>
                <td id="remainingCommonFragments">0</td>
                <td id="remainingRareFragments">0</td>
                <td id="remainingEpicFragments">0</td>
                <td id="remainingLegendaryFragments">0</td>
            </tr>
        </table>
        <h2 class="section-title">计算结果</h2>
        <div id="resultContainer"></div>
    </div>

    <script>
        document.getElementById('calculateBtn').addEventListener('click', calculate);
        
        function calculate() {
            // 获取用户输入
            // 剩余天数
            const remainingDays = parseInt(document.getElementById('remainingDays').value);
            // 剩余神品队员奖励次数
            const remainingLegendaryMember = parseInt(document.getElementById('remainingLegendaryMember').value);
            // 本周未掉落神品碎片数量
            const weeklyLegendaryDrops = parseInt(document.getElementById('weeklyLegendaryDrops').value);
            // 已获得队长奖励
            const hasLegendLeader = document.getElementById('hasLegendLeader').value === 'true';
            // 已获得队员奖励
            const hasLegendMember = document.getElementById('hasLegendMember').value === 'true';
            // 队长奖励星级
            const legendLeaderStar = parseInt(document.getElementById('legendLeaderStar').value);
            // 队员奖励星级
            const legendMemberStar = parseInt(document.getElementById('legendMemberStar').value);
            
            // 当前碎片
            // 随机碎片
            const randomFragments = parseInt(document.getElementById('randomFragments').value);
            // 凡品碎片
            const commonFragments = parseInt(document.getElementById('commonFragments').value);
            console.log(commonFragments);
            // 珍品碎片
            const rareFragments = parseInt(document.getElementById('rareFragments').value);
            // 绝品碎片
            const epicFragments = parseInt(document.getElementById('epicFragments').value);
            // 神品碎片
            const legendaryFragments = parseInt(document.getElementById('legendaryFragments').value);
            
            
            // 当前藏宝图
            const commonTreasureMap = parseInt(document.getElementById('commonWind').value);
            // const commonThunder = parseInt(document.getElementById('commonThunder').value);
            // const commonWater = parseInt(document.getElementById('commonWater').value);
            // const commonFire = parseInt(document.getElementById('commonFire').value);
            
            const rareTreasureMap = parseInt(document.getElementById('rareWind').value);
            // const rareThunder = parseInt(document.getElementById('rareThunder').value);
            // const rareWater = parseInt(document.getElementById('rareWater').value);
            // const rareFire = parseInt(document.getElementById('rareFire').value);
            
            const epicTreasureMap = parseInt(document.getElementById('epicWind').value);
            // const epicThunder = parseInt(document.getElementById('epicThunder').value);
            // const epicWater = parseInt(document.getElementById('epicWater').value);
            // const epicFire = parseInt(document.getElementById('epicFire').value);
            
            const legendaryTreasureMap = parseInt(document.getElementById('legendaryWind').value);
            // const legendaryThunder = parseInt(document.getElementById('legendaryThunder').value);
            // const legendaryWater = parseInt(document.getElementById('legendaryWater').value);
            // const legendaryFire = parseInt(document.getElementById('legendaryFire').value);
            
            // 秘闻碎片
            const secretRandomFragments = parseInt(document.getElementById('secretRandomFragments').value);
            const secretCommonFragments = parseInt(document.getElementById('secretCommonFragments').value);
            const secretRareFragments = parseInt(document.getElementById('secretRareFragments').value);
            const secretEpicFragments = parseInt(document.getElementById('secretEpicFragments').value);
            const secretLegendaryFragments = parseInt(document.getElementById('secretLegendaryFragments').value);
            
            // 属性碎片
            const windFragments = parseInt(document.getElementById('windFragments').value);
            const thunderFragments = parseInt(document.getElementById('thunderFragments').value);
            const waterFragments = parseInt(document.getElementById('waterFragments').value);
            const fireFragments = parseInt(document.getElementById('fireFragments').value);
            const universalFragments = parseInt(document.getElementById('universalFragments').value);
            
            // 目标碎片
            // const targetWind = parseInt(document.getElementById('targetWind').value);
            // const targetThunder = parseInt(document.getElementById('targetThunder').value);
            // const targetWater = parseInt(document.getElementById('targetWater').value);
            // const targetFire = parseInt(document.getElementById('targetFire').value);
            const targetUniversal = parseInt(document.getElementById('targetUniversal').value);
            
            // 计算最坏情况下的碎片获取
            let result = calculateWorstCaseScenario(
                remainingDays, remainingLegendaryMember, weeklyLegendaryDrops,
                hasLegendLeader, hasLegendMember, legendLeaderStar, legendMemberStar,
                commonFragments, rareFragments, epicFragments, legendaryFragments, randomFragments,
                commonTreasureMap,
                rareTreasureMap,
                epicTreasureMap,
                legendaryTreasureMap,
                secretRandomFragments, secretCommonFragments, secretRareFragments, secretEpicFragments, secretLegendaryFragments,
                windFragments, thunderFragments, waterFragments, fireFragments, universalFragments
            );
            
            // 碎片转换
            // result = optimizeFragments(result, targetWind, targetThunder, targetWater, targetFire, targetUniversal);
            
            // 显示结果
            displayResults(result, targetUniversal);
        }
        
        function calculateWorstCaseScenario(
            remainingDays, remainingLegendaryMember, weeklyLegendaryDrops,
            hasLegendLeader, hasLegendMember, legendLeaderStar, legendMemberStar,
            commonFragments, rareFragments, epicFragments, legendaryFragments, randomFragments,
            commonTreasureMap,
            rareTreasureMap,
            epicTreasureMap,
            legendaryTreasureMap,
            secretRandomFragments, secretCommonFragments, secretRareFragments, secretEpicFragments, secretLegendaryFragments,
            windFragments, thunderFragments, waterFragments, fireFragments, universalFragments
        ) {
            // 初始化结果对象
            let result = {
                universal: universalFragments,
                wind: windFragments,
                thunder: thunderFragments,
                water: waterFragments,
                fire: fireFragments,
                commonFragments, 
                rareFragments, 
                epicFragments, 
                legendaryFragments, 
                randomFragments,
                unknown: 0
            };
            console.log(result);
            
            // 计算每日奖励
            const dailyCommonMember = 3; // 每天3次凡品队员奖励
            const dailyRareMember = 2;   // 每天2次珍品队员奖励
            const dailyEpicMember = 1;   // 每天1次绝品队员奖励
            const weeklyLegendaryMember = 2; // 每周2次神品队员奖励
            
            // 计算剩余周数
            const remainingWeeks = Math.floor(remainingDays / 7);

            result.legendaryFragments += remainingWeeks * 3 + weeklyLegendaryDrops;


            // 每日队员奖励
            result.universal += remainingDays * (dailyCommonMember * 3 + dailyRareMember * 5 + dailyEpicMember * 10);
            result.unknown += remainingDays * (dailyCommonMember * 2 + dailyRareMember * 4 + dailyEpicMember * 8);

            result.commonFragments += dailyCommonMember * remainingDays;
            result.rareFragments += dailyRareMember * remainingDays;
            result.epicFragments += dailyEpicMember * remainingDays;
            
            
            // 神品队员奖励 (包括本周剩余次数和未来周数)
            // 本周剩余次数
            result.universal += Math.min(remainingLegendaryMember) * 20;
            result.unknown += Math.min(remainingLegendaryMember) * 15;
            
            // // 未来周数 (减去当前周)
            // const futureWeeks = remainingDays > 7 ? remainingWeeks - 1 : 0;
            // result.universal += futureWeeks * weeklyLegendaryMember * 20;
            // result.unknown += futureWeeks * weeklyLegendaryMember * 15;
            
            
            
            
            // 传颂藏宝图奖励
            if (!hasLegendLeader) {
                switch (legendLeaderStar) {
                    case 1: result.universal += 90; break;
                    case 2: result.universal += 120; break;
                    case 3: result.universal += 150; break;
                    case 4: result.universal += 180; break;
                }
            }
            
            if (!hasLegendMember) {
                switch (legendMemberStar) {
                    case 1: result.universal += 45; break;
                    case 2: result.universal += 60; break;
                    case 3: result.universal += 75; break;
                    case 4: result.universal += 90; break;
                }
            }
            
            // 秘闻碎片
            result.randomFragments += secretRandomFragments;
            result.commonFragments += secretCommonFragments;
            result.rareFragments += secretRareFragments;
            result.epicFragments += secretEpicFragments;
            result.legendaryFragments += secretLegendaryFragments;

            // 将随机碎片转换为藏宝图
            // 每日随机碎片
            const remainingDaysRandomFragments = remainingDays * 19;
            result.randomFragments += remainingDaysRandomFragments;
            commonTreasureMap += Math.floor(result.randomFragments / 10);
            result.randomFragments %= 10;
            
            // 藏宝图碎片计算

            // 凡品
            do {
                // 凡品碎片合成为藏宝图
                commonTreasureMap += Math.floor(result.commonFragments / 10);
                console.log("commonTreasureMap:", commonTreasureMap)
                // 计算合成后凡品碎片
                result.commonFragments = result.commonFragments % 10;

                console.log("result.commonFragments:", result.commonFragments)

                // 计算凡品碎片
                result.universal += commonTreasureMap * 5
                result.unknown += commonTreasureMap * 4;

                // 计算藏宝图结束后凡品碎片
                result.commonFragments += commonTreasureMap
                commonTreasureMap = 0

            } while(result.commonFragments >= 10);
            

            // 珍品
            do {
                // 珍品碎片合成为藏宝图
                rareTreasureMap += Math.floor(result.rareFragments / 10);
                // 计算合成后珍品碎片
                result.rareFragments = result.rareFragments % 10;

                // 计算珍品碎片
                result.universal += rareTreasureMap * 10
                result.unknown += rareTreasureMap * 8;

                // 计算藏宝图结束后珍品碎片
                result.rareFragments += rareTreasureMap
                rareTreasureMap = 0

            } while(result.rareFragments >= 10);

            // 绝品
            do {
                // 凡品碎片合成为藏宝图
                epicTreasureMap += Math.floor(result.epicFragments / 10);
                // 计算合成后凡品碎片
                result.epicFragments = result.epicFragments % 10;

                // 计算凡品碎片
                result.universal += epicTreasureMap * 20;
                result.unknown += epicTreasureMap * 16;

                // 计算藏宝图结束后凡品碎片
                result.epicFragments += epicTreasureMap
                epicTreasureMap = 0

            } while(result.epicFragments >= 10);

            // 计算神品碎片
            legendaryTreasureMap += Math.floor(result.legendaryFragments / 10);
            result.legendaryFragments %= 10
            result.universal += legendaryTreasureMap * 40;
            result.unknown += legendaryTreasureMap * 30;

            return result;
        }
        
        function optimizeFragments(result, targetWind, targetThunder, targetWater, targetFire, targetUniversal) {

            // 转换属性碎片为通用碎片以满足通用碎片需求
            const neededUniversal = Math.max(0, targetUniversal - result.universal);
            
            // 计算需要转换的属性碎片数量
            let totalConvertible = 0;
            const attributes = ['wind', 'thunder', 'water', 'fire'];
            
            // 计算可以转换的属性碎片总数
            for (const attr of attributes) {
                const needed = eval(`target${attr.charAt(0).toUpperCase() + attr.slice(1)}`);
                const available = result[attr];
                const surplus = Math.max(0, available - needed);
                totalConvertible += Math.floor(surplus / 2);
            }
            
            // 转换足够的属性碎片为通用碎片
            const universalToConvert = Math.min(neededUniversal, totalConvertible);
            let remainingToConvert = universalToConvert;
            
            for (const attr of attributes) {
                if (remainingToConvert <= 0) break;
                
                const needed = eval(`target${attr.charAt(0).toUpperCase() + attr.slice(1)}`);
                const available = result[attr];
                const surplus = Math.max(0, available - needed);
                const convertible = Math.floor(surplus / 2);
                const convert = Math.min(remainingToConvert, convertible);
                
                result[attr] -= convert * 2;
                result.universal += convert;
                remainingToConvert -= convert;
            }
            
            // 转换通用碎片为属性碎片以满足属性需求
            for (const attr of attributes) {
                const needed = eval(`target${attr.charAt(0).toUpperCase() + attr.slice(1)}`);
                const available = result[attr];
                const deficit = Math.max(0, needed - available);
                
                if (deficit > 0 && result.universal > 0) {
                    const convert = Math.min(deficit, result.universal);
                    result[attr] += convert;
                    result.universal -= convert;
                }
            }
            
            // 处理未知碎片 (假设全部转换为通用碎片)
            result.universal += Math.floor(result.unknown / 2);
            result.unknown = result.unknown % 2;
            
            return result;
        }
        
        function displayResults(result, targetUniversal) {

            document.getElementById("remainingRandomFragments").innerHTML = result.randomFragments
            document.getElementById("remainingCommonFragments").innerHTML = result.commonFragments
            document.getElementById("remainingRareFragments").innerHTML = result.rareFragments
            document.getElementById("remainingEpicFragments").innerHTML = result.epicFragments
            document.getElementById("remainingLegendaryFragments").innerHTML = result.legendaryFragments

            const resultContainer = document.getElementById('resultContainer');
            resultContainer.innerHTML = '';
            
            // 创建结果表格
            const table = document.createElement('table');
            
            // 表头
            const thead = document.createElement('thead');
            const headerRow = document.createElement('tr');
            ['', '风', '雷', '水', '火', '通用', '未知'].forEach(text => {
                const th = document.createElement('th');
                th.textContent = text;
                headerRow.appendChild(th);
            });
            thead.appendChild(headerRow);
            table.appendChild(thead);
            
            // 表体
            const tbody = document.createElement('tbody');
            
            // 保底碎片
            const guaranteeUniversalRow = document.createElement('tr');
            guaranteeUniversalRow.innerHTML = `
                <th>保底算法</th>
                <td>${result.wind}</td>
                <td>${result.thunder}</td>
                <td>${result.water}</td>
                <td>${result.fire}</td>
                <td>${result.universal}</td>
                <td>${result.unknown}</td>
            `;
            tbody.appendChild(guaranteeUniversalRow);
            
            // 转换碎片
            const convertUniversalRow = document.createElement('tr');
            convertUniversalRow.innerHTML = `
                <th>转换后碎片</th>
                <td>${result.wind % 2}</td>
                <td>${result.thunder % 2}</td>
                <td>${result.water % 2}</td>
                <td>${result.fire % 2}</td>
                <td>${result.universal + Math.floor(result.wind / 2) + Math.floor(result.thunder / 2) + Math.floor(result.water / 2) + Math.floor(result.fire / 2) + Math.floor(result.unknown / 2) }</td>
                <td>${result.unknown % 2}</td>
            `;
            tbody.appendChild(convertUniversalRow);
            
            // // 雷属性
            // const thunderRow = document.createElement('tr');
            // thunderRow.innerHTML = `
            //     <td>雷</td>
            //     <td>${result.thunder}</td>
            //     <td>${targetThunder}</td>
            //     <td>${result.thunder >= targetThunder ? '✓' : '✗'}</td>
            // `;
            // tbody.appendChild(thunderRow);
            
            // // 水属性
            // const waterRow = document.createElement('tr');
            // waterRow.innerHTML = `
            //     <td>水</td>
            //     <td>${result.water}</td>
            //     <td>${targetWater}</td>
            //     <td>${result.water >= targetWater ? '✓' : '✗'}</td>
            // `;
            // tbody.appendChild(waterRow);
            
            // // 火属性
            // const fireRow = document.createElement('tr');
            // fireRow.innerHTML = `
            //     <td>火</td>
            //     <td>${result.fire}</td>
            //     <td>${targetFire}</td>
            //     <td>${result.fire >= targetFire ? '✓' : '✗'}</td>
            // `;
            // tbody.appendChild(fireRow);
            
            // // 未知属性
            // const unknownRow = document.createElement('tr');
            // unknownRow.innerHTML = `
            //     <td>未知属性</td>
            //     <td>${result.unknown}</td>
            //     <td>-</td>
            //     <td>-</td>
            // `;
            // tbody.appendChild(unknownRow);
            
            table.appendChild(tbody);
            resultContainer.appendChild(table);
            
            // 添加总结
            // const summary = document.createElement('div');
            // summary.style.marginTop = '20px';
            // summary.style.padding = '10px';
            // summary.style.backgroundColor = '#f0f0f0';
            // summary.style.borderRadius = '4px';
            
            // const allTargetsMet = result.universal >= targetUniversal &&
            //                      result.wind >= targetWind &&
            //                      result.thunder >= targetThunder &&
            //                      result.water >= targetWater &&
            //                      result.fire >= targetFire;
            
            // if (allTargetsMet) {
            //     summary.innerHTML = '<p style="color: green; font-weight: bold;">恭喜！按照当前进度，在活动结束时可以达成所有目标。</p>';
            // } else {
            //     summary.innerHTML = '<p style="color: red; font-weight: bold;">注意：按照当前进度，在活动结束时可能无法达成所有目标。</p>';
                
            //     // 计算需要额外购买的天数
            //     const deficitUniversal = Math.max(0, targetUniversal - result.universal);
            //     const deficitWind = Math.max(0, targetWind - result.wind);
            //     const deficitThunder = Math.max(0, targetThunder - result.thunder);
            //     const deficitWater = Math.max(0, targetWater - result.water);
            //     const deficitFire = Math.max(0, targetFire - result.fire);
                
            //     if (deficitUniversal > 0 || deficitWind > 0 || deficitThunder > 0 || deficitWater > 0 || deficitFire > 0) {
            //         const dailyGainUniversal = 3*3 + 2*5 + 1*10 + (2/7)*20 + 19; // 每日通用碎片获取
            //         const dailyGainUnknown = 3*2 + 2*4 + 1*8 + (2/7)*15; // 每日未知属性获取
            //         const dailyGainFromUnknown = Math.floor(dailyGainUnknown / 2); // 每日从未知属性转换的通用碎片
                    
            //         const totalDailyGainUniversal = dailyGainUniversal + dailyGainFromUnknown;
                    
            //         // 计算最大赤字
            //         const totalDeficit = deficitUniversal + deficitWind + deficitThunder + deficitWater + deficitFire;
            //         const daysNeeded = Math.ceil(totalDeficit / totalDailyGainUniversal);
                    
            //         summary.innerHTML += `<p>估计需要额外购买约 ${daysNeeded} 天的资源才能在剩余时间内达成目标。</p>`;
            //     }
            // }
            
            // resultContainer.appendChild(summary);
        }
    </script>
</body>
</html>